/*
 * Systemprogrammierung
 * Multiplayer-Quiz
 *
 * Server
 *
 * loader.h: Header für die Loader-Steuerung
 */

#ifndef SLOADER_H
#define SLOADER_H

/* ... */

#include "common/server_loader_protocol.h"
#include "common/question.h"

#define LOADER_PROCCESSNAME "loader"

#define LOADER_PIPEERROR -1
#define LOADER_PIPESENDSUCCESS 4
#define LOADER_PIPECREATEERROR -3
#define LOADER_PIPESENDERROR -4
#define LOADER_PIPESRECEIVEERROR -5
#define LOADER_PIPEUNKNOWNERROR -6
#define LOADER_PROCESSCREATIONERROR -8
#define LOADER_CATALOGMANAGERERROR -12

int loader_StartLoader();
int loader_ForkLoaderProcess();
int loader_ReadCatalogsFromLoader();
int loader_WriteToPipe(char* sMessage, size_t iLength);
int loader_LoadCatalog(char *sCatalogName, int iCatalogLen);
int loader_OpenSharedMemory(int iAmountQuestions);
Question* loader_GetQuestion(int iQIndex);
void loader_UnlinkSharedMemory();
int loader_SendNextQuestion(int iUserID);
int loader_SendTimeoutPackage(int iUserID);
int loader_checkAnswer(int iUserID, int selectedIndex);
int loader_SendGameOver();
int loader_CheckGameEnd();


#endif
